package com.itgone.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itgone.annotation.IgnoreResultAdvice;
import com.itgone.entity.TBlog;
import com.itgone.service.TBlogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (TBlog)表控制层
 *
 * @author Earlman
 * @since 2024-04-02 09:43:12
 */
@Api(description = "[TBlog]表控制层")
@RestController
@RequestMapping("tBlog")
public class TBlogController {
    /**
     * 服务对象
     */
    @Resource
    private TBlogService tBlogService;

    /**
     * 分页查询所有数据
     *
     * @param page  分页对象
     * @param tBlog 查询实体
     * @return 所有数据
     */
    @IgnoreResultAdvice
    @ApiOperation("分页查询所有数据")
    @GetMapping
    public Object selectAll(Page<TBlog> page, TBlog tBlog) {
        return this.tBlogService.page(page, new QueryWrapper<>(tBlog));
    }

    /**
     * 分页查询所有数据1
     *
     * @param page  分页对象
     * @param tBlog 查询实体
     * @return 所有数据
     */
    @ApiOperation("分页查询所有数据1")
    @GetMapping("1")
    public Object selectAll1(Page<TBlog> page, TBlog tBlog) {
        return this.tBlogService.page(page, new QueryWrapper<>(tBlog));
    }

    @ApiOperation("分页查询所有数据1")
    @GetMapping("2")
    public Object selectAll12() {
        throw new RuntimeException("1234");
    }


    /**
     * 新增数据
     *
     * @param tBlog 实体对象
     * @return 新增结果
     */
    @ApiOperation("新增数据")
    @PostMapping
    public Object insert(@RequestBody TBlog tBlog) {
        return this.tBlogService.save(tBlog);
    }

}

